
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import lombok.Data;
import org.junit.jupiter.api.Test;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Set;


public class test1 {

    @Test
    public void testClass() throws Exception{
        String gsonString = "{\"name\":\"hello\"}";
        Gson gson = new Gson();
        JsonObject jsonObject = gson.fromJson(gsonString, JsonObject.class);
        Set<Map.Entry<String, JsonElement>> entries = jsonObject.entrySet();
        for (Map.Entry<String,JsonElement> entry:entries){
            System.out.println(entry.getKey());
            System.out.println(entry);
        }
        Set<String> strings = jsonObject.keySet();
        System.out.println(strings);
        for(String s:strings){
            System.out.println(s);
        }
//        Class<user> userClass = user.class;
//        for (Field field : userClass.getDeclaredFields()) {
//            String fieldName = field.getName();
//            if (jsonObject.has(fieldName)) {
//                System.out.println("Key " + fieldName + " exists in gson.");
//            } else {
//                System.out.println("Key " + fieldName + " does not exist in gson.");
//            }
//        }


    }
}
@Data
class user{
    String username;
    int age;
}
